# Maintainer: Yusuke Sasaki <y_sasaki@nuem.nagoya-u.ac.jp>

_realname=gtest
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.7.0
pkgrel=1
pkgdesc="Google Test (mingw-w64)"
arch=('any')
url="https://github.com/google/googletest"
license=('custom:BSD3')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("https://github.com/google/googletest/archive/release-${pkgver}.tar.gz")
sha256sums=("f73a6546fdf9fce9ff93a5015e0333a8af3062a152a9ad6bcb772c96687016cc")

build() {
  cd googletest-release-$pkgver

  rm -rf build
  rm -rf fused-src
  mkdir build
  cd build

  cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON -DCMAKE_SKIP_RPATH=ON ..
  make

  ../scripts/fuse_gtest_files.py .. ../fused-src
}

package() {
  cd googletest-release-$pkgver

  mkdir -pm 0755 "$pkgdir"/${MINGW_PREFIX}/{bin,lib,include/gtest/internal,share/licenses/$pkgname,src/gtest/src,src/gtest/cmake}
  install -m 0644 build/libgtest{,_main}.dll "$pkgdir"/${MINGW_PREFIX}/bin
  install -m 0644 build/libgtest{,_main}.dll.a "$pkgdir"/${MINGW_PREFIX}/lib
  install -m 0644 include/gtest/*.h "$pkgdir"/${MINGW_PREFIX}/include/gtest
  install -m 0644 include/gtest/internal/*.h "$pkgdir"/${MINGW_PREFIX}/include/gtest/internal/
  install -m 0644 LICENSE "$pkgdir"/${MINGW_PREFIX}/share/licenses/$pkgname/
  install -m 0644 fused-src/gtest/* "$pkgdir"/${MINGW_PREFIX}/src/gtest/src/
  install -m 0644 CMakeLists.txt "$pkgdir"/${MINGW_PREFIX}/src/gtest/
  install -m 0644 cmake/* "$pkgdir"/${MINGW_PREFIX}/src/gtest/cmake/
}

# vim: set ft=sh ts=2 sw=2 et :
